package com.zlzxm.shoesmarket.view.fragment;

import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.lifecycle.ViewModelProvider;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import com.zlzxm.shoesmarket.R;
import com.zlzxm.shoesmarket.util.ZViewHelp;
import com.zlzxm.shoesmarket.view.adapter.ADRepositoryInOutNote;
import com.zlzxm.shoesmarket.viewmodel.VMRepositoryInOutNote;

/**
 * CREATE BY zlzxm ON 4/14/21
 */
public class FMRepositoryInOutNote extends BaseFragment{


    private VMRepositoryInOutNote vmRepositoryInOutNote;

    private ADRepositoryInOutNote adRepositoryInOutNote = new ADRepositoryInOutNote();

    private RecyclerView recyclerView;

    @Nullable
    @Override
    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container,
                             @Nullable Bundle savedInstanceState) {
        return inflater.inflate(R.layout.fragment_statistic_repository_note,container,false);
    }

    @Override
    protected void initView(@NonNull View view, @NonNull Bundle savedInstanceState) {
        super.initView(view, savedInstanceState);

        recyclerView = ZViewHelp.findById(view,R.id.recyclerView);
        recyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
    }

    @Override
    protected void initViewModel() {
        super.initViewModel();
        vmRepositoryInOutNote = new ViewModelProvider(this).get(VMRepositoryInOutNote.class);
        vmRepositoryInOutNote.getLiveNote().observe(this,adRepositoryInOutNote::setList);
    }

    @Override
    protected void initData() {
        super.initData();
        recyclerView.setAdapter(adRepositoryInOutNote);

        vmRepositoryInOutNote.requestNote();
    }
}
